﻿using System;

namespace NinjaToolbox.SubComponentModule
{
    [Serializable]
    public struct Union
    {
        public static readonly Union Empty = new Union() { type = EType.Max };

        public enum EType { Int, Float, String, Bool, Max }
        public EType type;
        public int intValue;
        public float floatValue;
        public string stringValue;
        public bool boolValue;


        public static Union From(int value)
        {
            return new Union() { intValue = value, type = EType.Int };
        }

        public static Union From(float value)
        {
            return new Union() { floatValue = value, type = EType.Float };
        }

        public static Union From(string value)
        {
            return new Union() { stringValue = value, type = EType.String };
        }

        public static Union From(bool value)
        {
            return new Union() { boolValue = value, type = EType.Bool };
        }

    }
}
